package top.hudk.design.observer;

import java.util.TreeMap;

/**
 * 作用：测试观察者模式
 *
 * @author hudk
 * @date 2020/12/11 9:40
 */
public class Test {

    public static void main(String[] args) {
        //创建被观察者，上课铃响
        ISubject subject = new LessonBellSubject();
        //学生观察者，观察上课铃响
        IObserver studentObserver = new StudentObserver(subject);
        //老师观察者，观察上课铃响
        IObserver teacherObserver = new TeacherObserver(subject);
        //铃响事件发生，会逐一执行注册好的观察者回调方法，相当于通知观察者执行相应的逻辑
        subject.bellRings();
    }
}
